#include<iostream>
using namespace std;
#include<vector>
#include<string>
#include<algorithm>
#include<limits.h>
int main() {
	string T, S;
	cin >> S >> T;
	int n1 = S.size(), n2 = T.size();
	vector<vector<int>> dp(n1+1, vector<int>(n2+1,0));
	for (int i = 0; i <= n2; ++i)
		for (int j = i + 1; j <= n2; ++j)
			dp[i][j] = 9999;
	dp[0][0] = 0;
	for (int i = 1; i <= n1; ++i) {
		dp[i][0] = 0;
		for (int j = 1; j <= n2; ++j) {
			if (S[i - 1] == T[j - 1])
				dp[i][j] = dp[i - 1][j - 1];
			else
				dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - 1] + 1);
		}
	}
	cout << dp[n1][n2];
}